<?php echo $this->element('displayHeader'); ?>

<!-- View Site Inventory -->
<?php if ($session->read('Auth.User.is_head_user') == true || $session->read('Auth.User.can_view_other_site') == true) : // ถ้าเป็น Site user และ ดู site อื่นได้
    $user = $session->read('Auth.User'); ?>
<div class="viewSiteInventory">
        <?php echo $ajax->form('CustProductSites', 'post', array('update' => 'content', 'indicator' => 'indicator','url' => array('controller' => 'cust_product_sites', 'action' => 'change_view_site')));
        echo 'View Site Inventory ' . $form->select('view_site_inventory', $this->requestAction('sites/site_list/'. $user['customer_id'] . '/allOption:true'),
                isset($user['Extend']['view_site_inventory'])? $user['Extend']['view_site_inventory']: $user['site_id'],
                array('id' => 'viewSiteInventory', 'name' => 'data[view_site_inventory]'), false);
        echo $form->submit('submit', array('class' => 'hide', 'id' =>'viewSiteInventorySubmit'));
        echo $form->end();
        ?>
    <script type="text/javascript">
        $j("#viewSiteInventory").bind("change", function(event) {
            $j("#viewSiteInventorySubmit").trigger("click");
        });
    </script>
</div>
<?php endif; ?>

<div class="toolbar" <?php echo ($session->read('Auth.User.is_head_user') == false && $session->read('Auth.User.can_view_other_site') == true)? 'style="clear: both; position: relative; top: -5px"': null; ?>>
    <?php echo $this->element('toolbar', array('buttons' => array(
        array('search' => array('controller' => 'cust_product_sites')), 'refresh',
        array('print' => array('model' => 'CustProductSite', 'action' => 'print_display', 'params' => $site_id)),
       array('excel' => array('model' => 'CustProductSite', 'action' => 'excel_display', 'params' => $site_id))))); ?>
</div>

<?php
$i_display = strpos($this->here, 'display');
if ($i_display > 0) {
    $params = substr($this->here, $i_display + 8);
} else {
    $params = '';
}
if ($site_id == 'All') {
    echo $this->requestAction('cust_product_sites/display_all/' . $params, array('return'));
} else {
    echo $this->requestAction('cust_product_sites/display_site/' . $params, array('return'));
}
?>